<?php

/* 
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
namespace app\admin\controller;


/**
 * 栏目管理控制器
 */
class Column extends AdminBase
{
    /**
     * 栏目列表
     * @return type
     */
    public function columnList()
    {      
        $where = $this->logicColumn->getWhere($this->param);
        
        $this->assign('list', $this->logicColumn->getColumnList($where));
        
        return $this->fetch('column_list');
    }
    
    /**
     * 栏目添加
     * @return type
     */
    public function columnAdd()
    {
        $this->columnCommon();
        
        $this->assign('info', []);
        
        return $this->fetch('column_edit');
    }
    
    /**
     * 保存栏目
     */
    public function columnEdit()
    {         
        $this->columnCommon();
        
        $info = $this->logicColumn->getColumnInfo(['a.id' => $this->param['id']]);
 
        $this->assign('info', $info);
        
        return $this->fetch('column_edit');
    }
    
    /**
     * 删除栏目
     */
    public function columnDelete()
    {
        
    }
    
    /**
     * 更改栏目状态
     */
    public function setStatus()
    {
       $this->jump($this->logicAdminBase->setStatus('Column', $this->param));
    }


    /**
     * 栏目添加与编辑通用方法
     */
    public function columnCommon()
    {
        IS_POST && $this->jump($this->logicColumn->columnEdit($this->param));//判断是否表单提交 是则跳转保存处理

        $this->assign('column_category_list', $this->logicColumn->getColumnCategoryList([], 'id,name', '', false));//返回分类列表
    }
}
